
<script language="javascript">
function updateOption(currentValue, listIndex, relatedListID ,relatedListUniqueID)
{
	var i, nextValue = 0;
	var index = listIndex + 1;
	var thisLists = "lists_" + relatedListID;
	var xmlDataID = "xml_" + relatedListID;

//	alert(currentValue);
//	alert(listIndex);
//	alert("ok");
	if (listIndex >= eval(thisLists + ".length") - 1)
	{
		updateInput(relatedListID);
		return;
	}
		
	var tmpID = eval(thisLists + "[index]");
	with(document.getElementById(tmpID))
	{
		length = 0;
		
		if (currentValue != 0)
		{
			var nodes = document.all(xmlDataID).XMLDocument.selectSingleNode('//*'  + '[@value="' + currentValue + '"]');
			
		
			if (nodes.childNodes.length > 0)
			{
		
				nextValue = nodes.childNodes[0].getAttribute("value");
				for (i = 0; i < nodes.childNodes.length; i++)
				{
				
					var j = length++;
					options[j].text = nodes.childNodes[i].getAttribute("text");
					options[j].value = nodes.childNodes[i].getAttribute("value");
				}
			}
			else
			{
				var j = length++;
				options[j].text = "";
				options[j].value = 0;
			}
			
		}
		else
		{
			var j = length++;
			options[j].text = "";
			options[j].value = 0;
		}
	}
	
	var onchange = new Function("updateOption(" + nextValue + "," + index + ",'" + relatedListID + "','"+relatedListUniqueID+"')");
	onchange();	
	
}

function updateInput(relatedListID)
{

	var i, j;
	var thisLists = "lists_" + relatedListID;
	
	with(document.getElementById(relatedListID))
	{
		
		value = "";		
		for (i = 0; i < eval(thisLists + ".length"); i++)
		{
			
			j = document.getElementById(eval(thisLists + "[i]")).selectedIndex;
			value += (document.getElementById(eval(thisLists + "[i]")).options[j].value + "\x03");
		}
		
	}

}

</script>

